package com.example.controller;

import com.example.entity.result.Result;
import com.example.entity.result.ResultBean;
import com.example.entity.vo.Order;
import com.example.service.OrderService;
import com.example.utils.DataUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/home")
@RestController
public class HomeController extends BaseHandleException {

    @Autowired
    private OrderService orderService;

    //预约
    @RequestMapping("/reservation")
    public ResultBean reservation(@RequestParam("cid") String cid, @RequestParam("uid") String uid,
                                  @RequestParam("start") String start, @RequestParam("end") String end) {
        Order order = new Order(DataUtils.paramToInteger(cid), DataUtils.paramToInteger(uid), start, end);
        Result result = orderService.insertOrder(order);
        return DataUtils.getResultBean(result);
    }


}
